<template>
  <div class="process-layout">
    <el-form :model="model" :inline="true" label-width="auto">
      <el-form-item label="工艺规程编号" prop="procedureCode">
        <el-input :value="model.procedureCode" />
      </el-form-item>
      <el-form-item label="版次" prop="versions">
        <el-input :value="model.versions" />
      </el-form-item>
      <el-form-item label="零件名称" prop="partName">
        <el-input :value="model.partName" />
      </el-form-item>
      <el-form-item label="零件图号" prop="partMap">
        <el-input :value="model.partMap" />
      </el-form-item>
    </el-form>
    <TablePro
      class="table-box"
      :data="data"
      :columns="columns"
      :show-tools="false"
      :border="true"
      @row-dblclick="(row) => change('processContent', row)"
    />
  </div>
</template>

<script setup lang="ts">
import TablePro from "@/components/TablePro/TablePro.vue";
import type { TableProCloumn, TabType } from "@/typings";
import { ref } from "vue";

interface Model {
  [key: string]: any;
}

type Props = {
  model: Model;
  data: any[];
  change: (val: TabType, row: any) => void;
};

defineProps<Props>();
const columns = ref<TableProCloumn[]>([
  {
    label: "工序号",
    align: "center",
    prop: "processCode",
    width: 100
  },
  {
    label: "工序名称",
    align: "center",
    prop: "processName",
    width: 200
  },
  {
    label: "工种",
    align: "center",
    prop: "workType",
    width: 100
  },
  {
    label: "设备",
    align: "center",
    _children: [
      {
        label: "名称",
        align: "center",
        prop: "deviceName"
      },
      {
        label: "型号",
        align: "center",
        width: 200,
        prop: "deviceModel"
      },
      {
        label: "数控系统",
        align: "center",
        prop: "deviceOs"
      }
    ]
  },
  {
    label: "工装",
    align: "center",
    _children: [
      {
        label: "名称",
        align: "center",
        prop: "toolName"
      },
      {
        label: "图号",
        align: "center",
        prop: "toolMap"
      }
    ]
  },
  {
    label: "备注",
    align: "center",
    prop: "remark",
    width: 200
  }
]);
</script>

<style scoped lang="scss">
.process-layout {
  width: 100%;
  height: 100%;
  :deep(.el-form) {
    .el-form-item {
      margin-bottom: 10px;
    }
  }
  .table-box {
    height: calc(100% - 42px);
  }
}
</style>
